package ru.ifmo.rybakov.muclumon.pes;

import java.io.StringReader;
import java.math.BigInteger;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;

import ru.ifmo.rybakov.muclumon.pes.sri.SequenceRunInfo;

public class Main {
	public static void main(String[] args) {
		SequenceRunInfo info = new SequenceRunInfo();
		info.setId(BigInteger.valueOf(123));
		SequenceRunInfo.Step step = new SequenceRunInfo.Step();
		step.setTaskId("task_id");
		info.getStep().add(step);
		try {
			JAXBContext jc = JAXBContext.newInstance( "ru.ifmo.rybakov.muclumon.pes.sri" );
			Marshaller m = jc.createMarshaller();
			m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
			m.marshal(info, System.out);
			
			String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><sequenceRunInfo id=\"123\"><step order=\"0\" taskId=\"task_id\"/></sequenceRunInfo>";
			Unmarshaller um = jc.createUnmarshaller();
			info = (SequenceRunInfo) um.unmarshal(new StringReader(xml));
			System.out.println(info.getId());
		} catch (Exception e) {
			System.out.println(e);
			e.printStackTrace();
		}
		
		
	}
}
